<template>
  <el-pagination
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="currentPage"
    :page-sizes="pageSizes"
    :page-size="pageSize"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total" style="text-align: right">
  </el-pagination>
</template>

<script>
export default {
  name: 'hyl-pagination',
  data () {
    return {
      currentPage: 1,
      limit: 5,
      page: 1
    }
  },
  props: {
    total: Number,
    'page-sizes': {
      type: Array,
      default: function () {
        return [5, 7, 10]
      }
    },
    'page-size': {
      type: Number,
      default: 5
    }
  },
  methods: {
    handleSizeChange (val) {
      // console.log(`每页 ${val} 条`)
      this.limit = val
      this.$emit('fetch', {
        page: this.page,
        limit: this.limit
      })
    },
    handleCurrentChange (val) {
      this.page = val
      this.$emit('fetch', {
        page: this.page,
        limit: this.limit
      })
    }
  },
  mounted: function () {
  }
}
</script>

<style scoped>

</style>
